#!/usr/bin/python
"""
Only For Development!
"""

import level1
import time

interface = level1.LPT() # open the Port

testcable =	(
			("all off", 		0,0,0,0,0,0,0,0),
			("all on",			1,1,1,1,1,1,1,1),
			("right to left",	0,0,0,0,0,0,0,0),
			("",				0,0,0,0,0,0,0,1),
			("", 				0,0,0,0,0,0,1,0),
			("", 				0,0,0,0,0,1,0,0),
			("", 				0,0,0,0,1,0,0,0),
			("", 				0,0,0,1,0,0,0,0),
			("", 				0,0,1,0,0,0,0,0),
			("", 				0,1,0,0,0,0,0,0),
			("", 				1,0,0,0,0,0,0,0),
			("left to right",	0,0,0,0,0,0,0,0),
			("", 				1,0,0,0,0,0,0,0),
			("",		 		0,1,0,0,0,0,0,0),
			("",		 		0,0,1,0,0,0,0,0),
			("",		 		0,0,0,1,0,0,0,0),
			("",		 		0,0,0,0,1,0,0,0),
			("",		 		0,0,0,0,0,1,0,0),
			("",		 		0,0,0,0,0,0,1,0),
			("",		 		0,0,0,0,0,0,0,1),
			("fill from right", 0,0,0,0,0,0,0,0),
			("", 				0,0,0,0,0,0,0,1),
			("", 				0,0,0,0,0,0,1,1),
			("", 				0,0,0,0,0,1,1,1),
			("", 				0,0,0,0,1,1,1,1),
			("", 				0,0,0,1,1,1,1,1),
			("", 				0,0,1,1,1,1,1,1),
			("", 				0,1,1,1,1,1,1,1),
			("defill from right",1,1,1,1,1,1,1,1),
			("", 				1,1,1,1,1,1,1,0),
			("", 				1,1,1,1,1,1,0,0),
			("", 				1,1,1,1,1,0,0,0),
			("", 				1,1,1,1,0,0,0,0),
			("", 				1,1,1,0,0,0,0,0),
			("", 				1,1,0,0,0,0,0,0),
			("", 				1,0,0,0,0,0,0,0),
			("", 				0,0,0,0,0,0,0,0),
			)

def testD(sequence):
	global interface
	for i in sequence:
		print "number=%i" % i
		interface.set(i)
		time.sleep(.25) #additional delay
	return

def testB(sequence):
	global interface
	for i in sequence:
		t = ""
		for bit in i[1:]:
			if bit == 0:
				t+="_"
			else:
				t+="X"
		data = 	i[8] + \
				i[7] * 2 + \
				i[6] * 4 + \
				i[5] * 8 + \
				i[4] * 16 + \
				i[3] * 32 + \
				i[2] * 64 + \
				i[1] * 128
		if len(i[0]) > 0:
			print i[0]
		print "("+t+") number: "+str(data)
		interface.set(data)
		time.sleep(.25) #additional delay
	print "done."
	return


if __name__ == "__main__":
	testB(testcable)